Utilize `if let` over single branch `match`.
authorCorey Farwell <coreyf@rwell.org>
Fri, 6 May 2016 01:36:13 +0000 (21:36 -0400)
committerCorey Farwell <coreyf@rwell.org>
Fri, 6 May 2016 01:36:13 +0000 (21:36 -0400)
src/cargo/core/package_id_spec.rs

index a643713b279720e7218b238f9cd947eacd434062..031249393661f20fbc11cca166a48609179b01d3 100644 (file)
@@ -17,14 +17,12 @@ pub struct PackageIdSpec {
 impl PackageIdSpec {
     pub fn parse(spec: &str) -> CargoResult<PackageIdSpec> {
         if spec.contains("/") {
-            match spec.to_url() {
-                Ok(url) => return PackageIdSpec::from_url(url),
-                Err(..) => {}
+            if let Ok(url) = spec.to_url() {
+                return PackageIdSpec::from_url(url);
             }
             if !spec.contains("://") {
-                match Url::parse(&format!("cargo://{}", spec)) {
-                    Ok(url) => return PackageIdSpec::from_url(url),
-                    Err(..) => {}
+                if let Ok(url) = Url::parse(&format!("cargo://{}", spec)) {
+                    return PackageIdSpec::from_url(url);
                 }
             }
         }